/********************************************************************
	filename: 	Rectangle2D.h
	created:	2010/04/17
	author:		Xiuwei Chen

	purpose:	Definition of class 2D Rectangle

	All rights Reserved
*********************************************************************/

#pragma once

#include "Const.h"
#include "Vector2D.h"

class GEOMETRY_EXPORT Rectangle2D
{
public:
	/// <Summary>
	/// Zero of Rectangle2D
	/// </Summary>
	const static Rectangle2D Zero;

	/// <Summary>
	/// bound of Rectangle
	/// </Summary>
	double x0, y0, x1, y1;

	/// <Summary>
	/// default constructor
	/// </Summary>
	Rectangle2D();

	/// <Summary>
	/// copy constructor
	/// </Summary>
	Rectangle2D(const Rectangle2D &rect);

	/// <Summary>
	/// constructor
	/// </Summary>
	Rectangle2D(double _x0, double _y0, double _x1, double _y1);

	/// <Summary>
	/// constructor
	/// </Summary>
	Rectangle2D(const Point2D &p0, const Point2D &p1);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(double _x0, double _y0, double _x1, double _y1);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(const Point2D &p0, const Point2D &p1);

	/// <Summary>
	/// overload operation: assignment
	/// </Summary>
	Rectangle2D & operator = (const Rectangle2D &rect);

	/// <Summary>
	/// overload operation: "=="
	/// </Summary>
	bool operator == (const Rectangle2D &rect) const;

	/// <Summary>
	/// overload operation: "!="
	/// </Summary>
	bool operator != (const Rectangle2D &rect) const;

	/// <Summary>
	/// overload operation: "<"
	/// </Summary>
	bool operator < (const Rectangle2D &rect) const;

	/// <Summary>
	/// overload operation: "+"
	/// </Summary>
	Rectangle2D operator + (const Rectangle2D &rect) const;


	/// <Summary>
	/// overload operation: "+="
	/// </Summary>
	Rectangle2D & operator += (const Rectangle2D &rect);


	/// <Summary>
	/// Translation by 2D vector
	/// </Summary>
	void Translation(const Vector2D &v);

	/// <Summary>
	/// 2D rectangle Normalize
	/// </Summary>
	void Normalize();

	/// <Summary>
	/// Height (Y Axis)
	/// </Summary>
	double Height() const;

	/// <Summary>
	/// Width (X Axis)
	/// </Summary>
	double Width() const;

	/// <Summary>
	/// Area
	/// </Summary>
	double Area() const;

	/// <Summary>
	/// Center
	/// </Summary>
	Point2D Center() const;

	/// <Summary>
	/// merge rectangle
	/// </Summary>
	void Merge(const Rectangle2D &rect);
};
